import MatterManager from '../../managers/MatterManager'

export default class GroundMatter extends Laya.Script{
    /** @prop {name: label, tips: '要填', type: String}*/
    label: string;
  

    private matterManage =  MatterManager.instance;
    private container: Laya.Sprite;
    private ground: any;

    constructor() {
        super();
    }

    public onAwake(){
        this.container = this.owner as Laya.Sprite;
        this.ground = this.matterManage.produceRect(this.container.x+this.container.width/2,
                                                    this.container.y+this.container.height/2,
                                                    this.container.width,
                                                    this.container.height);   
        
        if(this.label === 'up'){
            this.ground.collisionFilter = {
                category: 2, 
                mask: 1, 
                group:0
            };
        }else if(this.label === 'down'){
            this.ground.collisionFilter = {
                category: 2, 
                mask: 1, 
                group:0
            };           
        }
        this.matterManage.addToWorld(this.ground);

        //this.owner as Laya.Sprite();
    }

    
    //描边-->调试使用
    public drawGroundBorder(drawContainer: Laya.Sprite): void{
        this.matterManage.drawBodyBorder(drawContainer, this.ground.vertices);
    }

}